package javaWeb;

import Bean.Manager;
import Service.Impl.ManageServiceImpl;
import Service.ManageService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class ManagerServlet extends BasicServlet {
    ManageService manageService = new ManageServiceImpl();
    private void Login(HttpServletRequest req, HttpServletResponse resp){
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        Manager manager = new Manager();
        manager.setPassWord(password);
        manager.setUserName(username);
        HttpSession session = req.getSession();

        try {
            if (manageService.LoginManage(manager)){
                session.setAttribute("login",true);
                resp.sendRedirect("/Web/Furn/manage_menu.html");
            }else {
                session.setAttribute("login",false);
                req.getRequestDispatcher("/Manage/manage_login.html").forward(req,resp);
            }
        } catch (ServletException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
        }


    }
}
